package com.room.service;

import com.room.mapper.TeachaerMapper;
import com.room.pojo.Teachaer;
import com.room.pojo.vo.TeacherVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建人 lin
 * @创建时间 2019/10/14
 * @描述
 */
@Service
public class TeacherService {
   @Autowired
    TeachaerMapper teachaerMapper;

   //添加学生
    public int insertTea(Teachaer teachaer){
        return teachaerMapper.insert(teachaer);
    }

    //根据传进的id删除学生数据
    public boolean deleteTeaById(String ids){
        String[] split = ids.split(",");
        return teachaerMapper.deleteTeaById(split) == split.length;
    }

   public int updateTeacher(Teachaer teachaer){
       return teachaerMapper.updateByPrimaryKey(teachaer);
   }

    //根据分页获取学生数据
    public List<Teachaer> getTeaByPage(Integer page, Integer size){
        int start  = (page-1)* size;
        return teachaerMapper.getTeaByPage(start, size);
    }

    public long getTotal(){
        return teachaerMapper.getTotal();
    }

    //获取最大的学号
   public String getMaxId(){
        return teachaerMapper.getMaxId();
   }

//   获取教师的初始化数据
   public List<TeacherVO> getTeacherInit(){
        return teachaerMapper.getTeacherInit();
    }

  public String getPhoneFormName(String name){
        return teachaerMapper.getPhoneFormName(name);
  }

  //根据学号获取到教师数据
 public Teachaer  getTeacherByNo(String teacherNo){
        return teachaerMapper.getTeacherByNo(teacherNo);
  }

}
